package com.jams.goodox.activity.serve.visitor;

import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;

import com.jams.goodox.BaseActivity;
import com.jams.goodox.R;
import com.jams.goodox.adapter.CustomFragmentPagerAdapter;
import com.jams.goodox.utils.StyleUtil;

import java.util.ArrayList;
import java.util.List;

import butterknife.Bind;

/**
 * Created by jams_zhen on 2016/9/26.
 */

public class VisitorHistoryActivity extends BaseActivity {


    @Bind(R.id.tabLayout)
    TabLayout tabLayout;
    @Bind(R.id.viewPager)
    ViewPager viewPager;

    private List<Fragment> fragmentList;

    private VisitorHistoryFragment visitorHistoryFragment1;
    private VisitorHistoryFragment visitorHistoryFragment2;

    @Override
    protected int getLayoutId() {
        return R.layout.visitor_history_activity;
    }

    @Override
    protected void init() {
        StyleUtil.titleBackKey(this, "访客记录");
        fragmentList=new ArrayList<>();
        visitorHistoryFragment1=VisitorHistoryFragment.getInstance(false);//未到访客
        visitorHistoryFragment2=VisitorHistoryFragment.getInstance(true);//已到访客

        List<String> tabsTitle = new ArrayList<>();
        fragmentList.add(visitorHistoryFragment1);
        tabsTitle.add("未到访客");
        fragmentList.add(visitorHistoryFragment2);
        tabsTitle.add("已到访客");

        viewPager.setAdapter(new CustomFragmentPagerAdapter(getSupportFragmentManager(), tabsTitle, fragmentList));

        tabLayout.setupWithViewPager(viewPager);
        tabLayout.setTabMode(TabLayout.MODE_FIXED);
        tabLayout.setTabGravity(TabLayout.GRAVITY_FILL);
    }

}
